package com.sino.tb.confirm.entiry;

import java.sql.*;
import java.util.*;
import xpubbean.Db.*;

public class DeclareDetail {

	private String key;
	private String declareKey;
	private String declareItemKey;
	private String itemKeyValue;
	private String oldValue;
	private String oldURL;
	private String newValue;
	private String newURL;
	private String finalValue;
	private String reason;
	private String processKey;
	private DeclareTypeDetail item;
	private int itemStatus;
	private int itemType;

	public static DeclareDetail[] findAll(String key, Connection conn) {
		DeclareDetail[] result = null;
		String sql = "SELECT    t1.* , t2.c_item_status, t3.c_type " +
					 "FROM      t_pub_req2 t1, " +
					 "          t_st_declare_detail t2, " +
					 "          t_st_proj t3 " +
					 "WHERE     t1.c_seq_req = ? AND " +
					 "          t1.c_prj_seq = t2.c_seq AND " +
					 "          t2.c_item_seq = t3.c_seq " +
					 "ORDER BY  t1.c_seq , t2.c_seq ";
		try {
			PreparedStatement pstmt = conn.prepareStatement(sql);
			pstmt.setString(1, key);
			ResultSet rs = pstmt.executeQuery();
			ArrayList temp = new ArrayList();
			while (rs.next()) {
				DeclareDetail value = new DeclareDetail();
				value.setKey(rs.getString("c_seq"));
				value.setDeclareKey(rs.getString("c_seq_req"));
				value.setDeclareItemKey(rs.getString("c_prj_seq"));
				value.setItemKeyValue(rs.getString("c_keyword"));
				value.setOldValue(rs.getString("c_value_old"));
				value.setOldURL(rs.getString("c_value_old_disp"));
				value.setNewValue(rs.getString("c_value_new"));
				value.setNewURL(rs.getString("c_value_new_disp"));
				value.setFinalValue(rs.getString("c_value_final"));
				value.setReason(rs.getString("c_reason"));
				value.setProcessKey(rs.getString("c_rsp_seq"));
				value.setItemStatus(rs.getInt("c_item_status"));
				value.setItemType(rs.getInt("c_type"));
				DeclareTypeDetail dtd = DeclareTypeDetail.find(value.
					getDeclareItemKey(), conn);
				value.setItem(dtd);
				temp.add(value);
			}
			rs.close();
			pstmt.close();
			result = new DeclareDetail[temp.size()];
			ListIterator lit = temp.listIterator();
			int i = 0;
			while (lit.hasNext()) {
				result[i++] = (DeclareDetail) lit.next();
			}
			lit = null;
			temp = null;

		} catch (Exception e) {
			e.printStackTrace();
		}

		return result;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getDeclareKey() {
		return declareKey;
	}

	public void setDeclareKey(String declareKey) {
		this.declareKey = declareKey;
	}

	public String getDeclareItemKey() {
		return declareItemKey;
	}

	public void setDeclareItemKey(String declareItemKey) {
		this.declareItemKey = declareItemKey;
	}

	public String getItemKeyValue() {
		return itemKeyValue;
	}

	public void setItemKeyValue(String itemKeyValue) {
		this.itemKeyValue = itemKeyValue;
	}

	public String getOldValue() {
		return oldValue;
	}

	public void setOldValue(String oldValue) {
		this.oldValue = oldValue;
	}

	public String getOldURL() {
		return oldURL;
	}

	public void setOldURL(String oldURL) {
		this.oldURL = oldURL;
	}

	public String getNewValue() {
		return newValue;
	}

	public void setNewValue(String newValue) {
		this.newValue = newValue;
	}

	public String getNewURL() {
		return newURL;
	}

	public void setNewURL(String newURL) {
		this.newURL = newURL;
	}

	public String getFinalValue() {
		return finalValue;
	}

	public void setFinalValue(String finalValue) {
		this.finalValue = finalValue;
	}

	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}

	public String getProcessKey() {
		return processKey;
	}

	public void setProcessKey(String processKey) {
		this.processKey = processKey;
	}

	public DeclareTypeDetail getItem() {
		return item;
	}

	public void setItem(DeclareTypeDetail item) {
		this.item = item;
	}

	public int getItemStatus() {
		return itemStatus;
	}

	public void setItemStatus(int itemStatus) {
		this.itemStatus = itemStatus;
	}

	public int getItemType() {
		return itemType;
	}

	public void setItemType(int itemType) {
		this.itemType = itemType;
	}

}
